import random

vowels = [ 'a', 'e', 'i', 'o', 'u', 'y', ]
consonants = [ 'b', 'c', 'f','g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z', ]

def get_random_silable():
    firstchar = consonants[int(random.random()*len(consonants)//1)]
    secondchar = vowels[int(random.random()*len(vowels)//1)]
    return ""+firstchar+secondchar

def get_random_name():
    numof_silables = int( (random.random()*4//1) + 2 )
    name = []
    for i in range(0, numof_silables):
        name.append(get_random_silable())
    
    return ''.join(name)

from .models import StarSystem
from .models import  Game

def generate_game():
    game = Game( name = get_random_name() )
    game.save()
    generate_star_systems(game)

def generate_star_systems(agame):
    for i in range(0, int( random.random()*80//1 ) ):
        StarSystem(
            game=agame,
            name=get_random_name(),
            res1=random.random()*10//1,
            res2=random.random()*10//1,
            res3=random.random()*10//1,
            planets=random.random()*10//1,
            xpos=random.random()*32767//1,
            ypos=random.random()*32767//1,
        )
